import { PSMDAjaxControlContainerImpl } from '../psmdajax-control-container-impl';
import { IPSSysMap } from './ipssys-map';
import { IPSSysMapItem } from './ipssys-map-item';
import { IPSLanguageRes } from '../../res/ipslanguage-res';

export class PSSysMapImpl extends PSMDAjaxControlContainerImpl implements IPSSysMap {
  get codeName(): string {
    return this.M.codeName;
  }

  get emptyText(): string {
    return this.M.emptyText;
  }

  protected emptytextpslanguageres: IPSLanguageRes | null = null;

  getEmptyTextPSLanguageRes(): IPSLanguageRes | null {
    if (this.emptytextpslanguageres != null) return this.emptytextpslanguageres;
    const value = this.M.getEmptyTextPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.emptytextpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getEmptyTextPSLanguageRes') as IPSLanguageRes;
    return this.emptytextpslanguageres;
  }

  get emptyTextPSLanguageRes(): IPSLanguageRes | null {
    return this.getEmptyTextPSLanguageRes();
  }

  getEmptyTextPSLanguageResMust(): IPSLanguageRes {
    const value = this.getEmptyTextPSLanguageRes();
    if (value == null) {
      throw new Error('未指定无值内容语言资源');
    }
    return value;
  }

  get legendPos(): 'LEFT' | 'TOP' | 'RIGHT' | 'BOTTOM' | 'NONE' {
    return this.M.legendPos;
  }

  get mapStyle(): 'USER' | 'USER2' {
    return this.M.mapStyle;
  }

  protected pssysmapitems: IPSSysMapItem[] | null = null;

  getPSSysMapItems(): IPSSysMapItem[] | null {
    if (this.pssysmapitems == null) {
      this.pssysmapitems = this.fillChildListModel(this.M.getPSSysMapItems, 'control.map.IPSSysMapItem') as IPSSysMapItem[];
    }
    return this.pssysmapitems;
  }

  get psSysMapItems(): IPSSysMapItem[] | null {
    return this.getPSSysMapItems();
  }

  findPSSysMapItem(objKey: any): IPSSysMapItem | null {
    return this.getPSModel5('control.map.IPSSysMapItem', this.getPSSysMapItems(), objKey) as IPSSysMapItem;
  }

  get hasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  getHasWFDataItems(): boolean {
    return this.M.hasWFDataItems;
  }

  get cls(): string {
    return 'PSSysMapImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.map.IPSSysMap') return true;
    return super.instanceof(cls);
  }
}
